package com.gxa.wmcrm.dao.impl;


import com.gxa.wmcrm.dao.LoginDaoNew;
import com.gxa.wmcrm.pojo.LoginEntity;
import com.gxa.wmcrm.util.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.query.Query;

/**
 *
 * 登录 dao 的实现类
 *
 * hibernate完成功能
 *
 */
public class LoginDaoNewImpl implements LoginDaoNew {

    @Override
    public Long queryUser(LoginEntity loginEntity) {

        // 通过工具类获取session
        Session session = HibernateUtil.createSession();
        // 支持这一次业务的 HQL
        String hql = "select count(id) from LoginEntity " +
                "where username=:username and password=:password";
        Query query = session.createQuery(hql);
        // 将参数bean的值设置到对应的 param 位置
        query.setProperties(loginEntity);
        Long count = (Long) query.uniqueResult();
        System.out.println("-- count -- : " + count);
        return count;
    }
}


